home *** CD-ROM | disk | FTP | other *** search
- Path: cosy.sbg.ac.at!not-for-mail
- From: gwesp@cosy.sbg.ac.at (Gerhard Wesp)
- Newsgroups: comp.sys.cbm,gnu.gcc.help,de.comp.gnu,comp.sys.atari.8bit
- Subject: Re: GNU C-compiler port to 6502
- Date: 28 Mar 1996 14:57:04 GMT
- Organization: Dept. of CS, University of Salzburg
- Message-ID: <4je9c0$idd@esel.cosy.sbg.ac.at>
- References: <gnusenet199603252155.NAA11650@netcom9.netcom.com>
- NNTP-Posting-Host: barracuda.cosy.sbg.ac.at
-
- In article <gnusenet199603252155.NAA11650@netcom9.netcom.com>,
- Toshiyasu Morita <tm@netcom.com> wrote:
- :
- >Hmmm, which certain C code sequences?
- :
-
- Here goes the complete example:
- Let test.c be:
-
- char *p;
- foo()
- {
- while(*p);
- }
-
- Compiling it with cc65 -O2 -c test.c yields test.s:
-
- _foo
- Ltest1
- Ltest2
- ldx _p
- lda _p+1
- stx tmp
- sta tmp+1
- ldy #0
- lda (tmp),y
- sta tmp0
-
- lda #0
- ldx tmp0
- stx tmp0
- bpl *+4
- lda #$FF
- sta tmp0+1
-
- lda tmp0
- ora tmp0+1
- beq *+5
- jmp Ltest1
-
- rts
-
- _p
- RESERVE 2
-
-
- Note that this is the ORIC C-compiler found at
- http://www.dcs.ed.ac.uk/~axc/FLOOR1/oric.html#compiler
- (this is derived from lcc) and _not_ the ATARI cc65 from umich.edu.
- (Just the executable names coincide).
- (See also <4j6952$4pc@dodo.cosy.sbg.ac.at>. Well,
- the code I produced for the example is not really correct as Andre pointed
- out, but it can easily be corrected :-).
- Basically, lcc did a completely unnecessary integer promotion of *p (in
- my opinion unnecessary).
- I don't know if gcc would make better code, but I could well imagine
- it.
- The 6502 has simply too few native registers to get along with IMHO.
- How would you teach gcc to add 32 bit numbers with only an 8bit accu?
-
- Greetings,
- -Gerhard
-